package com.design.movieticket.service.Impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.design.movieticket.entity.Expend;
import com.design.movieticket.mapper.ExpendMapper;
import com.design.movieticket.service.ExpendService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ExpendServiceImpl extends ServiceImpl<ExpendMapper, Expend> implements ExpendService {
    @Resource
    private ExpendMapper expendMapper;

    /** 分页查询 */
    @Override
    public LambdaQueryWrapper buildQuery(Expend expend) {
        LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(Expend.class)
                .eq(StringUtils.isNotBlank(expend.getExpendType()),Expend::getExpendType,expend.getExpendType());
        return lambdaQueryWrapper;
    }

    /** 分页相关 */
    @Override
    public <E extends IPage<Expend>> E page(E page, Wrapper<Expend> queryWrapper) {
        return super.page(page, queryWrapper);
    }

    /** 新增或更新支出数据 */
    @Override
    public void addOrUpdateExpendInfo(Expend expend) {
        super.saveOrUpdate(expend);
    }

    /** 获取支出信息详情 */
    @Override
    public Expend getExpendDetail(long id) {
        return super.getById(id);
    }

    /** 删除支出信息 */
    @Override
    public void delExpendById(long id) {
        super.removeById(id);
    }
}
